package cn.yr.oauth.manager;

import cn.yr.oauth.constants.OAuthEnum;
import me.zhyd.oauth.request.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class OAuthManager {

    @Autowired
    private AuthGiteeRequest authGiteeRequest;
    @Autowired
    private AuthGithubRequest authGithubRequest;
    @Autowired
    private AuthWeiboRequest authWeiboRequest;
    @Autowired
    private AuthQqRequest authQqRequest;
    @Autowired
    private AuthAlipayRequest authAlipayRequest;

    public AuthRequest getAuthRequest(String type) {

        if(type == null|| type == ""){
            throw new RuntimeException("请输入auth类型！");
        }
        if(type.equals(OAuthEnum.Gitee.getOauthType())){
            return authGiteeRequest;
        }
        if(type.equals(OAuthEnum.Github.getOauthType())){
            return authGithubRequest;
        }
        if(type.equals(OAuthEnum.Weibo.getOauthType())){
            return authWeiboRequest;
        }
        if(type.equals(OAuthEnum.QQ.getOauthType())){
            return authQqRequest;
        }
        if(type.equals(OAuthEnum.Alipay.getOauthType())){
            return authAlipayRequest;
        }
        return null;
    }

}
